package com.subsequent.controller;

import com.subsequent.service.DoctorsService;
import com.subsequent.vo.DoctorVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/doctors")
public class DoctorsController {

    @Autowired
    private DoctorsService doctorsService;

    @GetMapping("/list")
    public List<DoctorVO> list() {
        return doctorsService.listDoctorVO();
    }
    @GetMapping("/list2")
    public List<DoctorVO> list(
            @RequestParam(required = false) String doctorName,
            @RequestParam(required = false) Integer deptId,
            @RequestParam(required = false) Integer status,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
            @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime
    ) {
        return doctorsService.queryDoctors(doctorName, deptId, status, startTime, endTime);
    }

}